﻿namespace BM.Tools.WebControls.MForm.Controls.Helper.EventValidation
{
    using System.Collections.ObjectModel;

    /// <summary>
    /// A collection of <see cref="EventValidationNodeList" />.
    /// </summary>
    internal class EventValidationTree : KeyedCollection<string, EventValidationNodeList>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="EventValidationTree"/> class.
        /// </summary>
        /// <param name="idSeparator">
        /// The id separator.
        /// </param>
        public EventValidationTree(char idSeparator)
        {
            IdSeparator = idSeparator;
        }

        /// <summary>
        /// Gets id separator.
        /// </summary>
        public char IdSeparator
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets the hash name of the list.
        /// </summary>
        /// <param name="list">
        /// The event validation node list.
        /// </param>
        /// <returns>
        /// The hash name of the list.
        /// </returns>
        protected override string GetKeyForItem(EventValidationNodeList list)
        {
            return list.GetHashName(IdSeparator);
        }
    }
}
